home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_091 / adlrun / adlintrn.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  156 lines

  1. #include <stdio.h>
  2.  
  3. #include "adltypes.h"
  4. #include "adlprog.h"
  5. #include "builtins.h"
  6. #include "vstring.h"
  7. #include "adlrun.h"
  8.  
  9.  
  10. setdemon()
  11. {
  12.     assertargs( "$sdem", 1 );
  13.     if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMROUT) )
  14.     error( 4 );            /* Illegal routine for $sdem */
  15.     demons[ numd++ ] = ARG( 1 );
  16. }
  17.  
  18.  
  19. deldemon()
  20. {
  21.     int16
  22.     i;    /* Loop counter */
  23.  
  24.     assertargs( "$ddem", 1 );
  25.     for( i = 0; i < numd; i++ )
  26.     if( demons[ i ] == ARG( 1 ) )
  27.         break;
  28.     if( i < numd ) {
  29.     numd--;
  30.     for( ; i < numd; i++ )
  31.         demons[ i ] = demons[ i + 1 ];
  32.     }
  33. }
  34.  
  35.  
  36. setfuse()
  37. {
  38.     assertargs( "$sfus", 3 );    /* ($sfus actor rout nturns) */
  39.     if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMOBJ) )
  40.     error( 30 );            /* Illegal actor for $sfus */
  41.     if( (ARG( 2 ) < 0) || (ARG( 2 ) > NUMROUT) )
  42.     error( 5 );            /* Illegal routine for $sfus */
  43.     if( !routspace[ ARG( 2 ) ] )
  44.     return;                /* Don't bother with a null fuse */
  45.     f_actors[ numf ] = ARG( 1 );
  46.     fuses[ numf ] = ARG( 2 );
  47.     ftimes[ numf++ ] = currturn + ARG( 3 );
  48. }
  49.  
  50.  
  51. delfuse( act, which )
  52. int16
  53.     act,
  54.     which;
  55. {
  56.     int16
  57.     i;    /* Loop counter */
  58.  
  59.     for( i = 0; i < numf; i++ )
  60.     if( (fuses[ i ] == which) && (f_actors[ i ] == act) )
  61.         break;
  62.     if( i < numf ) {
  63.     numf--;
  64.     for( ; i < numf; i++ ) {
  65.         fuses[ i ] = fuses[ i + 1 ];
  66.         ftimes[ i ] = ftimes[ i + 1 ];
  67.         f_actors[ i ] = f_actors[ i + 1 ];
  68.     }
  69.     }
  70. }
  71.  
  72.  
  73. incturn()
  74. {
  75.     if( ARG( 0 ) == 2 )
  76.     /* The programmer specified an increment */
  77.     currturn += ARG( 1 );
  78.     else
  79.     /* The default increment is 1 */
  80.     currturn++;
  81.     execfuses();
  82. }
  83.  
  84.  
  85. retturn()
  86. {
  87.     RETVAL = currturn;
  88. }
  89.  
  90.  
  91. doprompt()
  92. {
  93.     assertargs( "$prompt", 1 );
  94.     if( (ARG( 1 ) < 0) || (ARG( 1 ) > NUMROUT) )
  95.     error( 6 );        /* Illegal routine for $prompt */
  96.     prompter = ARG( 1 );
  97. }
  98.  
  99.  
  100. setactor()
  101. {
  102.     assertargs( "$actor", 3 );
  103.     if( (ARG( 1 ) < 2) || (ARG( 1 ) > NUMOBJ) )
  104.     error( 7 );        /* Illegal object for $actor */
  105.     if( numact <  10 ) {
  106.     actlist[ numact ].actor = ARG( 1 );
  107.     actlist[ numact ].linebuf = actlist[ numact ].savebuf;
  108.     actlist[ numact ].interact = ARG( 3 );
  109.     if( ARG( 2 ) ) {
  110.         strncpy( actlist[ numact ].linebuf, virtstr( ARG( 2 ) ), SLEN - 1 );
  111.         actlist[ numact ].savebuf[ 79 ] = '\0';
  112.     }
  113.     else
  114.         *actlist[ numact ].linebuf = '\0';
  115.     numact++;
  116.     }
  117.     else {
  118.     printf( "Too many actors in actlist, ip = %ld.\n", ip );
  119.     head_term();
  120.     exit( -1 );
  121.     }
  122. }
  123.  
  124.  
  125. delactor( n )
  126. int16
  127.     n;
  128. {
  129.     int16
  130.     i;    /* Loop counter */
  131.  
  132.     for( i = 0; i < numact; i++ ) {
  133.     if( actlist[ i ].actor == n ) {
  134.         numact--;
  135. #if MULTIPLEX
  136.         if( actlist[ i ].ttyfile != (FILE *)0 ) {
  137.         fclose( actlist[ i ].ttyfile );
  138.         actlist[ i ].ttyfile = (FILE *)0;
  139.         }
  140. #endif
  141.         for( ; i < numact; i++ ) {
  142.         actlist[ i ].actor = actlist[ i + 1 ].actor;
  143.         strcpy( actlist[ i ].savebuf, actlist[ i + 1 ].linebuf );
  144.         actlist[ i ].linebuf = actlist[ i ].savebuf;
  145. #if MULTIPLEX
  146.         actlist[ i ].ttyfile = actlist[ i + 1 ].ttyfile;
  147.         strcpy( actlist[ i ].ttyname, actlist[ i + 1 ].ttyname );
  148. #endif
  149.         }
  150.         return;
  151.     }
  152.     }
  153. }
  154.  
  155. /*** EOF adlintrn.c ***/
  156.